import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('NailCollect')
export class NailCollect extends Component {
    @property([Node])
    points: Node[] = []
    colorType: number;

    
    public onFull: () => void;

    private _toPoint_n: number = 0
    public addNodeToPoint(nd_: Node) {
        const parent_nd = this.getNoChildPoint()
        if (parent_nd) {
            parent_nd.addChild(nd_)
            if (++this._toPoint_n) {
                console.error("NailCollect, 满了需要销毁")
            }
        }
    }

    private getNoChildPoint(): Node | null {
        for (let index = 0; index < this.points.length; index++) {
            const nd = this.points[index]
            if (nd.children.length == 0) {
                return nd
            }
        }
        return null
    }
}


